# -*- python -*-
# ex: set syntax=python:

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# See master.experimental/slaves.cfg for documentation.

slaves = [
  {
    'master': 'DartFYI',
    'builder': ['dart2js-linux-none-debug-hostchecked'],
    'hostname': 'slave100-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2js-linux-none-debug'],
    'hostname': 'slave130-c3',
    'os': 'linux',
   'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['androidvm-linux'],
    'hostname': 'slave131-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['pub-win'],
    'hostname': 'vm167-m3',
    'os': 'win',
    'version': 'win10',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['dart2jsdumpinfo-linux'],
    'hostname': 'slave117-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['pub-linux'],
    'hostname': 'slave107-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['pub-mac', 'dart2js-mac10.11-safarimobilesim'],
    'hostname': 'vm669-m3',
    'os': 'mac',
    'version': '10.11.4',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['ddc-linux-release'],
    'hostname': 'slave123-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['ddc-win-release'],
    'hostname': 'vm210-m3',
    'os': 'win',
    'version': 'win7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['ddc-mac-release'],
    'hostname': 'vm607-m3',
    'os': 'mac',
    'version': '10.7',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-linux-release-x64-checked'],
    'hostname': 'slave112-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-1-8'],
    'hostname': 'slave150-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-2-8'],
    'hostname': 'slave151-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-3-8'],
    'hostname': 'slave152-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-4-8'],
    'hostname': 'slave153-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-5-8'],
    'hostname': 'slave231-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-6-8'],
    'hostname': 'slave232-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-7-8'],
    'hostname': 'slave233-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-debug-x64-8-8'],
    'hostname': 'slave234-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-release-x64-1-6'],
    'hostname': 'slave147-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-release-x64-2-6'],
    'hostname': 'slave149-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-release-x64-3-6'],
    'hostname': 'slave154-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-release-x64-4-6'],
    'hostname': 'slave155-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-release-x64-5-6'],
    'hostname': 'slave235-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
  {
    'master': 'DartFYI',
    'builder': ['vm-kernel-precomp-linux-release-x64-6-6'],
    'hostname': 'slave236-c3',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
  },
]


# This is hack to eliminate the need for sharing code between master and
# clients. These channels are replicated in scripts/factory/dart/channels.py.
channel_postfixes = ['-be', '-dev', '-stable', '-integration']

def valid_for_channel(builder, channel):
  """ Returns true if we have this builder on this specific channel"""
  return channel != '-integration'

def is_channel_builder(builder):
  """Returns true if the builder name is already specific to a channel
  (i.e. the builder ends with a channel postfix)."""
  for postfix in channel_postfixes:
    if builder.endswith(postfix):
      return True
  return False

def duplicate_builders_in_slaves(slaves):
  """Traverses a list of slaves and duplicates the builders associated with each
  slave for every channel. The channels have specified the postfix."""
  for slave in slaves:
    all_builders = []
    for builder in slave.get('builder', ()):
      if (not is_channel_builder(builder)):
        for channel in channel_postfixes:
          # Some channels don't have all builders
          if valid_for_channel(builder, channel):
            all_builders.append('%s%s' % (builder, channel))
      else:
        all_builders.append(builder)
    slave['builder'] = all_builders
  return slaves

slaves = duplicate_builders_in_slaves(slaves)
